package com.aaa.member.service.impl;

import com.aaa.entity.MemberLevel;
import com.aaa.member.dao.MemberLevelDao;
import com.aaa.member.service.MemberLevelService;
import com.aaa.vo.MemberLevelVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.security.KeyStore;
import java.util.List;

/**
 * @author JYH
 * @version 1.0
 * @date 2023/3/1 16:46
 */
@Service
public class MemberLevelServiceImpl extends ServiceImpl<MemberLevelDao, MemberLevel> implements MemberLevelService {

    @Autowired
    private MemberLevelDao memberLevelDao;
    @Override
    public Result findMemberLevel(Integer currentPage, Integer pageSize, String name) {
        PageHelper.startPage(currentPage,pageSize);
        QueryWrapper<MemberLevel> wrapper = new QueryWrapper<>();
        wrapper.like(name!=null,"name",name);
        List<MemberLevel> memberLevels = memberLevelDao.selectList(wrapper);
        PageInfo<MemberLevel> pageInfo = new PageInfo<>(memberLevels);

        return new Result(2000,"成功",pageInfo);
    }

    @Override
    public Result queryByParam() {
        return new Result(2000,"成功",memberLevelDao.queryByParam());
    }

    @Override
    public Result add(MemberLevel memberLevel) {
        return new Result(2000,"成功",memberLevelDao.insert(memberLevel));
    }
}
